//
//  ONAlertConfirmView.m
//  OrderNow
//
//  Created by Binh on 3/27/14.
//  Copyright (c) 2014 Familly. All rights reserved.
//

#import "ONAlertConfirmView.h"

@implementation ONAlertConfirmView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertConfirmView" owner:self options:nil][0];
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame andText:(NSString*)strText
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertConfirmView" owner:self options:nil][0];
        _txtView.text=[NSString stringWithFormat:@"%@",strText];
    }
    _bgView.layer.cornerRadius = 5;
    return self;
}

- (id)initWithFrame:(CGRect)frame andText:(NSString*)strText andLableView:(NSString*)strLable
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self = [[NSBundle mainBundle] loadNibNamed:@"ONAlertConfirmView" owner:self options:nil][0];
        _txtView.text=[NSString stringWithFormat:@"%@",strText];
        _labtitle.text=[NSString stringWithFormat:@"%@",strLable];
    }
    _bgView.layer.cornerRadius = 5;
    return self;
}

- (IBAction)btClickOkAlertView:(id)sender {
    
    [UIView animateWithDuration:0.2f animations:^{
        [self setAlpha:0.0f];
    }completion:^(BOOL done){
        
        if (_delegate && [_delegate respondsToSelector:@selector(clickButtonOk:)]){ //
            [_delegate clickButtonOk:sender];
        }
        
        [self removeFromSuperview];
        
        
    }];
    
}

- (IBAction)btClickCancelAlertView:(id)sender {
    
    [UIView animateWithDuration:0.2f animations:^{
        [self setAlpha:0.0f];
    }completion:^(BOOL done){
        
        if (_delegate && [_delegate respondsToSelector:@selector(clickButtonCancel:)]){ //
            [_delegate clickButtonCancel:sender];
        }
        
        [self removeFromSuperview];
        
        
    }];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    [_btnCancel setTitle:NSLocalizedString(@"Cancel", nil) forState:UIControlStateNormal];
}

@end
